import { Module } from '@nestjs/common';
import { UserController } from './user.controller';
import { UserService } from './user.service';
import { ConfigModule, ConfigService } from '@nestjs/config';
// import { AuthService } from 'src/auth/auth.service';
import { AuthModule } from 'src/auth/auth.moudle';

@Module({
    controllers: [UserController],
    providers: [
        UserService,
        ConfigService,
        // {
        //   provide: 'CONFIGURATION(database)',
        //   useFactory: (configService: ConfigService) => configService.get('database'),
        //   inject: [ConfigService],
        // },
        // // 值提供器
        // {
        //   provide: 'VALUE_PROVIDER',
        //   useValue: {
        //     name: 'value',
        //     age: 18,
        //   },
        // },
        // 类提供器
        // {
        //   provide: ConfigService,
        //   useClass: AuthService,
        // }
        // 工厂提供器
        {
            provide: 'FACTORY_PROVIDER',
            useFactory: (configService: ConfigService) => {
                return {
                    name: 'factory',
                    age: 222,
                };
            },
            inject: [ConfigService],
        },
    ],
    exports: [UserService],
    imports: [
        AuthModule,
    ],
})
export class UserModule {
    constructor() {
        console.log('UserModule init');
    }
}
